#include <iostream>
#include <limits>
using std::cout;
using std::endl;
using std::cin;

void test(){
    cout << "请输入数字" << endl;
    int number;
    while(1){
        cin >> number;
        if(cin.eof() || cin.bad()){
            cout << "程序已经结束" << endl;
            break;
        }else if(cin.fail()){
            //清空缓冲区
            cin.clear();
            cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
            cout << "请输入一个数字" << endl;
        }else {
            //good
            cout << "number=" << number << endl;
        }
    }
}

int main()
{
    test();
    return 0;
}
